﻿//Copyright (c) Microsoft Corporation.  All rights reserved.

using Microsoft.Ted.Wacel;
using Microsoft.Ted.Wacel.Cache;
using System;

namespace Microsoft.Ted.Wacel.QuickStarts
{
    class Program
    {
        static void Main(string[] args)
        {
            #region Large Array

            Cache.Array<int> array = new Cache.Array<int>("my_array", long.MaxValue);
            array[12345] = 200;

            Console.WriteLine("Array member: " + array[12345]);

            #endregion

            #region Compressed Circular Buffer

            Cache.CompressedCircularBuffer buffer = new Cache.CompressedCircularBuffer("my_buffer", 1);
            buffer.Add("This is a message");
            buffer.Add("This is another message");

            var message = buffer[0];

            Console.WriteLine("Newest messgae in buffer: " + message);

            #endregion

            #region Queue

            Cache.Queue<double> queue = new Cache.Queue<double>("my_queue");
            queue.Enqueue(123.345);

            var value = queue.Dequeue();

            Console.WriteLine("Item sent via queue: " + value);
            #endregion

            #region Cube

            Cache.Cube cube = new Cache.Cube("TestCube");

            cube.Dimensions.Add("Time", Dimension.GetTimeDimensionMonthDays(2013));
            cube.Dimensions.Add("StatusCode", Dimension.CreateFlatDimension("StatusCodes", new string[] { "200", "404", "500", "503", "302" }));

            cube.Update(new { Time = "Jan18", StatusCode = "200", Value = 100 });

            var monthNode = cube.Query(new { Time = "Jan", StatusCode = "200" });

            Console.WriteLine("January summary: " + monthNode.Value);

            var monthSlice = cube.Drilldown(monthNode, "Time");

            Console.WriteLine("January details:");
            foreach (var point in monthSlice)
                Console.WriteLine(point.Coordinates[0].Name + "-" + point.Coordinates[1].Name + ": " + point.Value);
            #endregion
        }
    }
}
